<template>
  <div>
    <slot></slot>
  </div>
</template>

<script>
export default {
  name: "hmCollapse",
  props: {
    value: {
      type: Array,
      default: () => {
        return ["1"];
      },
    }
  },
  provide() {
    return {
      hmCollapseValue: this.value,
      hmCollapse: this,
    };
  },
  created() {
    this.$on("item-click", (name) => {
      let index = this.value.indexOf(name);
      if (index > -1) {
        this.value.splice(index, 1);
      } else {
        this.value.push(name);
      }
      //修改完后返回
      this.$emit("change", this.value);
    });
  },
};
</script>



<style lang="">
</style>